home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / ch1 / widgettree.C < prev   
Encoding:
C/C++ Source or Header  |  1995-05-03  |  3.1 KB  |  104 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ////////////////////////////////////////////////////////
  22. // Widgettree.C, Demonstrate a typical widget hierarchy
  23. ////////////////////////////////////////////////////////
  24. #include <Xm/Xm.h>
  25. #include <Xm/RowColumn.h>
  26. #include <Xm/Form.h>
  27. #include <Xm/ScrolledW.h>
  28. #include <Xm/DrawingA.h>
  29. #include <Xm/PushB.h>
  30.  
  31. #if (XlibSpecificationRelease>=5)
  32. void main ( int argc, char **argv )
  33. #else
  34. void main ( unsigned int argc, char **argv )
  35. #endif
  36. {
  37.     Widget       toplevel, rc, form, 
  38.     sw, runButton, 
  39.     quitButton, canvas;
  40.     XtAppContext app;
  41.     
  42.     toplevel = XtAppInitialize ( &app, "Widgettree", NULL, 0, 
  43.                 &argc, argv, NULL, NULL, 0 );
  44.     
  45.     // All other widgets are contained in a Form widget
  46.     
  47.     form = XtCreateManagedWidget ( "form", 
  48.                   xmFormWidgetClass,
  49.                   toplevel, 
  50.                   NULL, 0 );
  51.     
  52.     // Attach a RowColumn widget top along the top edge of the Form
  53.     
  54.     rc = XtVaCreateManagedWidget ( "rowcolumn", 
  55.                   xmRowColumnWidgetClass,
  56.                   form, 
  57.                   XmNleftAttachment,   XmATTACH_FORM,
  58.                   XmNrightAttachment,  XmATTACH_FORM,
  59.                   XmNtopAttachment,    XmATTACH_FORM,
  60.                   XmNbottomAttachment, XmATTACH_NONE,
  61.                   NULL );
  62.     
  63.     // A ScrolledWindow widget occupies the bottom portion
  64.     // of the window, and spans the entire width
  65.     
  66.     sw = XtVaCreateManagedWidget ( "sw", 
  67.                   xmScrolledWindowWidgetClass,
  68.                   form, 
  69.                   XmNleftAttachment,   XmATTACH_FORM,
  70.                   XmNrightAttachment,  XmATTACH_FORM,
  71.                   XmNbottomAttachment, XmATTACH_FORM,
  72.                   XmNtopWidget,        rc,
  73.                   XmNtopAttachment,  XmATTACH_WIDGET,
  74.                   NULL );
  75.     
  76.     // A DrawingArea widget provides a scrollable work area
  77.     
  78.     canvas =  XtCreateManagedWidget ( "canvas", 
  79.                      xmDrawingAreaWidgetClass,
  80.                      sw, 
  81.                      NULL, 0 );
  82.     
  83.     // Create various buttons as children of the RowColumn widget
  84.     
  85.     runButton = XtCreateManagedWidget ( "runButton", 
  86.                        xmPushButtonWidgetClass,
  87.                        rc, 
  88.                        NULL, 0 );
  89.     
  90.     quitButton = XtCreateManagedWidget ( "quitButton", 
  91.                     xmPushButtonWidgetClass,
  92.                     rc, 
  93.                     NULL, 0 );
  94.     
  95.     //
  96.     // Assign callbacks, etc. here
  97.     //
  98.     
  99.     // Realize all widgets and enter the main event loop
  100.     
  101.     XtRealizeWidget( toplevel );
  102.     XtAppMainLoop( app );
  103. }
  104.